import { _decorator, Component, Node } from "cc";
const { ccclass, property } = _decorator;
import { EventType } from "db://assets/Scripts/Enums/Events/EventsEnum";
import { CustomEventListener } from "db://assets/Scripts/Listener/CustomEventListener";
import {
  MovingCommand,
  TurnDirectionCommand,
} from "db://assets/Scripts/Enums/Events/ActionsEnum";

@ccclass("HandleBtnCtrl")
export class HandleBtnCtrl extends Component {
  public receptionParameter(event: any, frontParam: string) {
    console.log("receptionParameter: ", frontParam);
    const listener = CustomEventListener.getInstance();
    
    listener.dispatchEvent(EventType.START_NEW_GAME_EVENT, frontParam);
    listener.dispatchEvent(EventType.CANCEL_START_NEW_GAME, frontParam);
    listener.dispatchEvent(EventType.SUBMIT_NICK_NAME, frontParam);

    listener.dispatchEvent(MovingCommand.FORWARD_MOVE, frontParam);
    listener.dispatchEvent(MovingCommand.BACKWARD_MOVE, frontParam);
    listener.dispatchEvent(MovingCommand.LEFT_MOVE, frontParam);
    listener.dispatchEvent(MovingCommand.RIGHT_MOVE, frontParam);

    listener.dispatchEvent(TurnDirectionCommand.TURN_CLOCK_90, frontParam);
    listener.dispatchEvent(
      TurnDirectionCommand.TURN_COUNTER_CLOCK_90,
      frontParam
    );
  }
}
